var t = getApp();

Page({
    data: {
        integral: "",
        id: "",
        path: "",
        title: "",
        member_avatar: "",
        member_nickname: "xxx",
        activity_title: "活动标题",
        activity_explain: "",
        activity_average: "0.00"
    },
    onLoad: function(t) {
        t.activity_id ? this.setData({
            id: t.activity_id
        }) : wx.navigateBack({
            delta: 1
        });
        try {
            var a = wx.getStorageSync("integral");
            a && (this.setData({
                integral: a
            }), this.data.integral && wx.setNavigationBarTitle({
                title: this.data.integral + "推广"
            }));
        } catch (t) {}
        this._getData();
    },
    onReady: function() {},
    onShow: function() {
        wx.showShareMenu({
            withShareTicket: !1,
            menus: [ "shareAppMessage", "shareTimeline" ]
        }), this._share();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareTimeline: function() {
        var t = wx.getStorageSync("yz_uid");
        return {
            title: this.data.title,
            query: "share_tag=2&mid=".concat(t)
        };
    },
    onShareAppMessage: function(t) {
        return {
            title: this.data.title,
            path: this.data.path
        };
    },
    _getData: function() {
        var a = this, i = t.getNetAddresss("plugin.point-activity.Frontend.Modules.Activity.Controllers.receive-page.index");
        t._postNetWork({
            url: i,
            showToastIn: !1,
            data: {
                activity_id: a.data.id
            },
            success: function(t) {
                var i = t.data;
                if (1 == i.result) {
                    var e = i.data;
                    a.setData({
                        member_avatar: e.member_avatar,
                        member_nickname: e.member_nickname,
                        activity_title: e.activity_title,
                        activity_explain: e.activity_explain,
                        activity_average: e.activity_average
                    });
                } else wx.showToast({
                    icon: "none",
                    title: i.msg,
                    duration: 1500
                });
            },
            fail: function(t) {}
        });
    },
    _initShare: function() {
        var a = this, i = t.getNetAddresss("member.member.wxJsSdkConfig");
        t._postNetWork({
            url: i,
            showToastIn: !1,
            data: {},
            success: function(t) {
                var i = t.data;
                1 == i.result ? a._share(i.data) : wx.showToast({
                    icon: "none",
                    title: i.msg,
                    duration: 1500
                });
            },
            fail: function(t) {}
        });
    },
    _share: function() {
        var a = wx.getStorageSync("yz_uid"), i = t._isTextEmpty(this.data.member_nickname) ? this.data.activity_title : this.member_nickname + this.activity_title, e = "/packageB/member/IntegralPresent/IntegralPresent?share_tag=2&mid=" + a + "&activity_id=" + this.data.id;
        this.setData({
            title: i,
            path: e,
            uid: a
        });
    },
    receive: function() {
        var a = t.getNetAddresss("plugin.point-activity.Frontend.Modules.Activity.Controllers.receive.index");
        t._postNetWork({
            url: a,
            showToastIn: !1,
            data: {
                activity_id: this.data.id
            },
            success: function(t) {
                var a = t.data;
                1 == a.result ? wx.showToast({
                    icon: "none",
                    title: "领取成功",
                    duration: 1500
                }) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {}
        });
    }
});